use radio buttons for exclusive choice of timespec
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Thu, 25 Aug 2022 13:18:40 +0000 (07:18 -0600)
committertsteven4 <13596209+tsteven4@users.noreply.github.com>
Thu, 25 Aug 2022 13:18:40 +0000 (07:18 -0600)
for track filter start and stop times in GUI.

gui/filterdata.h
gui/filterwidgets.cc
gui/trackui.ui

index 00071541dd439572e442fc87d3443bd7486b9825..d61201d2352c51024533ef247d252d2b6891c2f3 100644 (file)
@@ -61,7 +61,7 @@ class TrackFilterData: public FilterData
 public:
   TrackFilterData():  title(false), titleString(QString()),
     move(false),  weeks(0), days(0), hours(0), mins(0), secs(0),
-    TZ(true),
+    localTime(true), utc(false),
     start(false),
     stop(false),
     pack(false), merge(false), split(false),
@@ -96,7 +96,8 @@ public:
     sg.addVarSetting(new DateTimeSetting("trks.startTime", startTime));
     sg.addVarSetting(new BoolSetting("trks.stop", stop));
     sg.addVarSetting(new DateTimeSetting("trks.stopTime", stopTime));
-    sg.addVarSetting(new BoolSetting("trks.TZ", TZ));
+    sg.addVarSetting(new BoolSetting("trks.localTime", localTime));
+    sg.addVarSetting(new BoolSetting("trks.utc", utc));
     sg.addVarSetting(new BoolSetting("trks.move", move));
     sg.addVarSetting(new IntSetting("trks.weeks", weeks));
     sg.addVarSetting(new IntSetting("trks.days", days));
@@ -117,7 +118,7 @@ public:
   QString titleString;
   bool move;
   int  weeks, days, hours, mins, secs;
-  bool TZ;
+  bool localTime, utc;
 
   bool start;
   QDateTime startTime;
index d6d5aa17b8044d704181d400a3bb576d3510cb93..2e638eae4be34ebe1ed2b8355ad47ab1c0fa1d6a 100644 (file)
@@ -69,7 +69,8 @@ TrackWidget::TrackWidget(QWidget* parent, TrackFilterData& tfd): FilterWidget(pa
   connect(ui.splitTimeCheck,   &QAbstractButton::clicked, this, &TrackWidget::splitTimeX);
   connect(ui.splitDistanceCheck,   &QAbstractButton::clicked, this, &TrackWidget::splitDistanceX);
 
-  connect(ui.TZCheck, &QAbstractButton::clicked, this, &TrackWidget::TZX);
+  connect(ui.localTime, &QAbstractButton::clicked, this, &TrackWidget::TZX);
+  connect(ui.utc, &QAbstractButton::clicked, this, &TrackWidget::TZX);
 
   ui.startEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss AP");
   ui.stopEdit->setDisplayFormat("dd MMM yyyy hh:mm:ss AP");
@@ -82,15 +83,16 @@ TrackWidget::TrackWidget(QWidget* parent, TrackFilterData& tfd): FilterWidget(pa
   // If the two timeSpecs match Qt5 and Qt6 behave the same.
   ui.startEdit->setTimeSpec(tfd.startTime.timeSpec());
   ui.stopEdit->setTimeSpec(tfd.stopTime.timeSpec());
-  // Force TZ data to be in sync with startTime & stopTime time spec.
-  // This makes sure the initial state of the TZCheck box is in agreement
-  // with the startTime::timeSpec and stopTime::timeSpec.
-  tfd.TZ = tfd.startTime.timeSpec() == Qt::LocalTime;
+  // Make sure the initial state of the localTime and utc radio buttons
+  // is in agreement with the startTime::timeSpec and stopTime::timeSpec.
+  tfd.localTime = tfd.startTime.timeSpec() == Qt::LocalTime;
+  tfd.utc = !tfd.localTime;
 
   // Collect the data fields.
   fopts << new BoolFilterOption(tfd.title,  ui.titleCheck);
   fopts << new BoolFilterOption(tfd.move,   ui.moveCheck);
-  fopts << new BoolFilterOption(tfd.TZ,     ui.TZCheck);
+  fopts << new BoolFilterOption(tfd.localTime,     ui.localTime);
+  fopts << new BoolFilterOption(tfd.utc,     ui.utc);
   fopts << new BoolFilterOption(tfd.start,  ui.startCheck);
   fopts << new BoolFilterOption(tfd.stop,   ui.stopCheck);
   fopts << new BoolFilterOption(tfd.pack,   ui.packCheck);
@@ -124,7 +126,8 @@ TrackWidget::TrackWidget(QWidget* parent, TrackFilterData& tfd): FilterWidget(pa
 //------------------------------------------------------------------------
 void TrackWidget::otherCheckX()
 {
-  ui.TZCheck->setEnabled(ui.stopCheck->isChecked() || ui.startCheck->isChecked());
+  ui.localTime->setEnabled(ui.stopCheck->isChecked() || ui.startCheck->isChecked());
+  ui.utc->setEnabled(ui.stopCheck->isChecked() || ui.startCheck->isChecked());
 
   ui.splitTimeSpin->setEnabled(ui.splitTimeCheck->isChecked());
   ui.splitTimeCombo->setEnabled(ui.splitTimeCheck->isChecked());
@@ -184,7 +187,7 @@ void TrackWidget::splitDistanceX()
 //------------------------------------------------------------------------
 void TrackWidget::TZX()
 {
-  if (ui.TZCheck->isChecked()) {
+  if (ui.localTime->isChecked()) {
     ui.startEdit->setTimeSpec(Qt::LocalTime);
     ui.stopEdit->setTimeSpec(Qt::LocalTime);
   } else {
index 2cbea7971dd19dfcb0ec6fbe25f095cc9d53515c..0fb85cb92359a534de131a301f4525b73a4b850c 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>663</width>
+    <width>675</width>
     <height>270</height>
    </rect>
   </property>
@@ -220,19 +220,6 @@ This option is used along with the stop to discard trackpoints that were recorde
        </property>
       </widget>
      </item>
-     <item row="3" column="3" rowspan="2">
-      <widget class="QCheckBox" name="TZCheck">
-       <property name="toolTip">
-        <string>If checked, time specified here is based on this computer's current time zone. </string>
-       </property>
-       <property name="whatsThis">
-        <string>If checked, the times specified here are based on the local computer's time zone.  Otherwise it is UTC.</string>
-       </property>
-       <property name="text">
-        <string>Local Time</string>
-       </property>
-      </widget>
-     </item>
      <item row="4" column="0">
       <widget class="QCheckBox" name="stopCheck">
        <property name="sizePolicy">
@@ -480,6 +467,38 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo
        </property>
       </widget>
      </item>
+     <item row="3" column="3" rowspan="2">
+      <widget class="QRadioButton" name="localTime">
+       <property name="toolTip">
+        <string>If checked, times specified here are based on this computer's current time zone.</string>
+       </property>
+       <property name="whatsThis">
+        <string>If checked, times specified here are based on this computer's current time zone.</string>
+       </property>
+       <property name="text">
+        <string>Local Time</string>
+       </property>
+       <attribute name="buttonGroup">
+        <string notr="true">buttonGroup</string>
+       </attribute>
+      </widget>
+     </item>
+     <item row="3" column="4" rowspan="2">
+      <widget class="QRadioButton" name="utc">
+       <property name="toolTip">
+        <string>If checked, times specified here are UTC.</string>
+       </property>
+       <property name="whatsThis">
+        <string>If checked, times specified here are UTC.</string>
+       </property>
+       <property name="text">
+        <string>UTC</string>
+       </property>
+       <attribute name="buttonGroup">
+        <string notr="true">buttonGroup</string>
+       </attribute>
+      </widget>
+     </item>
     </layout>
    </item>
    <item row="0" column="1">
@@ -512,4 +531,7 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo
  </widget>
  <resources/>
  <connections/>
+ <buttongroups>
+  <buttongroup name="buttonGroup"/>
+ </buttongroups>
 </ui>